package servlets;

import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import beans.DBHelper;

/**
 * Servlet implementation class DeleteApply
 */
@WebServlet("/DeleteApply")
public class DeleteApply extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public DeleteApply() {
        super();
        // TODO Auto-generated constructor stub
    }
    protected void handDeleteApply(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
    	try{
    		String jobid= request.getParameter("jobid");
    		System.out.println("job"+jobid);
    		Connection con=DBHelper.getConnection();
    		PreparedStatement ps=DBHelper.getprepareStatement(con,"delete from applyjob where jobid = ?");
    		ps.setString(1, jobid);
    		ps.executeUpdate();
    		}catch(Exception e){
    			e.printStackTrace();
    		}
    	request.getRequestDispatcher("ViewApplyJob").forward(request, response);
    }
	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		handDeleteApply(request,response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		handDeleteApply(request,response);

	}

}
